package top.cluski.tokendemo;

import cn.hutool.jwt.JWT;
import cn.hutool.jwt.JWTHeader;
import cn.hutool.jwt.JWTUtil;

import java.util.HashMap;
import java.util.Map;

public class JWTTestMain {

    public static void main(String[] args) {
        Map<String, Object> map = new HashMap<String, Object>() {
            private static final long serialVersionUID = 1L;
            {
                put("uid", Integer.parseInt("123"));
                put("expire_time", System.currentTimeMillis() + 1000 * 60 * 60);
            }
        };

        String rightToken = JWTUtil.createToken(map, "1234".getBytes());
        System.out.println(rightToken);

        final JWT jwt = JWTUtil.parseToken(rightToken);

        System.out.println(jwt.getHeader(JWTHeader.TYPE));
        System.out.println(jwt.getPayload("uid"));
        System.out.println(jwt.getPayload("expire_time"));
    }
}
